//
//  FirstViewController.swift
//  SwiftTest
//
//  Created by apple on 2018/3/21.
//  Copyright © 2018年 QiKai. All rights reserved.
//

import UIKit
import TZImagePickerController

class FirstViewController: UIViewController{
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "消息"
        creatUI();
    }
    @objc func creatUI(){

        let arr:[String] = ["登录","微信登录","选取多张图片","支付宝支付","第三方登录","rx","collection联动","collection动态加载","tableView自动布局","自定义下拉菜单栏"]
        var lastBut:UIButton?
        for i in 0..<arr.count {
            let but = UIButton.init()
            but.tag = 200 + i
            but.setTitle(arr[i], for: UIControl.State.normal)
            but.addTarget(self, action: #selector(butaction(sender:)), for: UIControl.Event.touchUpInside)
            but.backgroundColor = UIColor.randomColor
            self.view.addSubview(but)
            but.snp.makeConstraints { (make) in
                make.size.equalTo(CGSize.init(width: 200, height: 23))
                make.centerX.equalToSuperview()
                if lastBut != nil{
                    make.top.equalTo(lastBut!.snp.bottom).offset(20)
                }else{
                     make.top.equalTo(50)
                }
            }
            lastBut = but
        }
        
    }
    
    

}
extension FirstViewController{
    @objc func butaction(sender:UIButton){
        let index:Int = sender.tag - 200
        switch index {
        case 0:
            let vv = SecondViewController()
            self.navigationController?.pushViewController(vv, animated: true)
        case 1:
            print("dd")
        case 2:
            let impick = TZImagePickerController.init(maxImagesCount: 5, delegate: self as TZImagePickerControllerDelegate)
            self.present(impick!, animated: true, completion: nil)
        case 3:
            ThirdPay.shared.ThirdPayTopay(type: .alipay)
        case 4:
            ThirdPay.shared.ThirdPayTopay(type: .alipay)
        case 5:
            let vv = RXViewController()
            self.navigationController?.pushViewController(vv, animated: true)
        case 6:
            let vv = CollectionLinkageViewController()
            self.navigationController?.pushViewController(vv, animated: true)
            
        case 7:
            let vv = CollectionMoveViewController()
            self.navigationController?.pushViewController(vv, animated: true)
         
        case 8:
            let vv = AutomaticLayoutTableviewViewController()
            self.navigationController?.pushViewController(vv, animated: true)
        case 9:
            let vv =  MenuTestViewController()
            self.navigationController?.pushViewController(vv, animated: true)
        default:
            print("dd")
        }
        
    }
}
extension FirstViewController:ThirdPayDelegate{
    func sucessAlipay() {
        
    }
    
    func faileAlipay() {
        
    }
    
}

extension FirstViewController:TZImagePickerControllerDelegate{
    func imagePickerController(_ picker: TZImagePickerController!, didFinishPickingVideo coverImage: UIImage!, sourceAssets asset: PHAsset!) {
        
        
    }
    func imagePickerController(_ picker: TZImagePickerController!, didFinishPickingPhotos photos: [UIImage]!, sourceAssets assets: [Any]!, isSelectOriginalPhoto: Bool) {
        print("\(String(describing: photos))")
    }
    
}











